package coint.btc.monitor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;

import coint.btc.jpa.RizhiJpa;
import coint.btc.pojo.Rizhi;


@SuppressWarnings("all")
@Component
public class MessageReceiver {
	private Logger log=LoggerFactory.getLogger(MessageReceiver.class);
	
	@Autowired
    private RizhiJpa logJpa;
	 /**
	  * 
	  * @Description: 接收消息的方法
	  * @date:2018年7月24日   
	  * @author: lt
	  * @param message 消息体
	  */
   
	public void receiveMessage(String message){
    	try {
    		JSON json=JSON.parseObject(message);
    		log.info("-------收到一条消息:receiveMessage:{}------",message);
    		Rizhi systemLog= JSON.toJavaObject(json, Rizhi.class);
    		logJpa.save(systemLog);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}
